package com.ax.service.imple;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;

import com.ax.pojo.TabDown;
import com.ax.service.TabDownService;
import com.ax.utils.BaseDaoSupport;
import com.ax.utils.PageInfo;

@Service("tabDownService")
public class TabDownServiceImle implements TabDownService {

	
	private BaseDaoSupport<TabDown> dao;
	
	@Resource(name="sessionFactory")
	public void setSessionFactort(SessionFactory sessionFactory){
		 dao=new BaseDaoSupport<TabDown>();
		 dao.setSessionFactory(sessionFactory);
	}
	public boolean delDown(TabDown tabDown) {
		boolean flag=true;
		try {
			dao.delete(tabDown);
		} catch (Exception e) {
			// TODO: handle exception
			flag=false;
		}
		return flag;
	}

	public PageInfo findPageInfo(int currentPageSize, String cond) {
		PageInfo pageInfo=new PageInfo();
		pageInfo.setData(dao.getPaginationData(cond, currentPageSize, pageInfo.getPageSize(), TabDown.class, null));
		pageInfo.setTotalCount(((Long)dao.getDataCount(TabDown.class, cond)).intValue());
		pageInfo.setCurPage(currentPageSize);
		return pageInfo;
	}

	public TabDown getDown(int id) {
		// TODO Auto-generated method stub
		return (TabDown)dao.getHibernateTemplate().get(TabDown.class, id);
	}

	public boolean saveDown(TabDown tabDown) {
		boolean flag=true;
		try {
			dao.save(tabDown);
		} catch (Exception e) {
			// TODO: handle exception
			flag=false;
		}
		return flag;
	}

	public boolean updateDown(TabDown tabDown) {
		boolean flag=true;
		try {
			dao.update(tabDown);
		} catch (Exception e) {
			// TODO: handle exception
			flag=false;
		}
		return flag;
	}
	public List<TabDown> findDowns() {
		// TODO Auto-generated method stub
		return dao.findAll(TabDown.class);
	}

}
